/**
 * @param {number[]} flowers
 * @param {number} cnt
 * @return {number}
 */
var beautifulBouquet = function (flowers, cnt) {
  let left = 0,
    right = 0,
    res = 0,
    hash = {},
    MOD = 1e10 + 7
  while (right < flowers.length) {
    let temp = flowers[right]
    hash[temp] = hash[temp] + 1 || 1
    console.log(hash[temp]);
    while (hash[temp] > cnt) {
      hash[flowers[left]]--
      left++
    }
    res += (right - left + 1) % MOD
    right++
  }
  return res
}

beautifulBouquet([1, 2, 3, 2],1)
